﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace NinjaToolbox.SubComponentModule.Example
{
    public class SE2_Idle : SubComponent<SE2_Idle_Model>
    {
        Animator mCacheAnimator;
        SE2_FSM mFSM;


        protected override void SubComponent_OnEnable()
        {
            base.SubComponent_OnEnable();

            mCacheAnimator = (mContext.Owner as MonoBehaviour).GetComponentInChildren<Animator>();
            mFSM = mContext.Container.GetSubComponent<SE2_FSM>();
        }

        protected override void SubComponent_Update()
        {
            base.SubComponent_Update();

            if (mFSM.CurrentState != SE2_FSM.StateEnum.Idle)
            {
                return;
            }

            mCacheAnimator.Play(Model.idleAnimKey);
        }
    }
}
